package com.raylinks;

/**
 * Created by ljb on 17/1/11.
 */

public class ModuleControl {
    public static native int UhfReaderConnect(String port, int baudRate, byte flagCrc);
    public static native boolean UhfReaderDisconnect(int fileDescriptor, byte flagCrc);
    public static native boolean UhfGetPaStatus(int fileDescriptor, byte[] status, byte flagCrc);
    public static native boolean UhfGetPower(int fileDescriptor, byte[] power, byte flagCrc);
    public static native boolean UhfSetPower(int fileDescriptor, byte option, byte power, byte flagCrc);

    public static native boolean UhfGetFrequency(int fileDescriptor, byte[] uFreMode,byte[] uFreBase, byte[] uBaseFre, byte[] uChannNum, byte[] uChannSpc, byte[] uFreHop, byte flagCrc);
    public static native boolean UhfSetFrequency(int fileDescriptor, byte uFreMode, byte uFreBase, byte[] uBaseFre, byte uChannNum, byte uChannSpc, byte uFreHop, byte flagCrc);
    public static native boolean UhfGetReaderUID (int fileDescriptor, byte[] uUid, byte flagCrc);

    public static native boolean UhfStartInventory(int fileDescriptor, byte flagAnti, byte initQ, byte flagCrc);
    public static native boolean UhfReadInventory(int fileDescriptor, byte[] bLenUii, byte[] bUii);
    public static native boolean UhfStopOperation(int fileDescriptor, byte flagCrc);
    public static native boolean UhfInventorySingleTag(int fileDescriptor, byte[] bLenUii, byte[] bUii, byte flagCrc);
    public static native boolean UhfReadDataByEPC(int fileDescriptor, byte[] bAccessPwd, byte bank, byte[] bPtr, byte cnt, byte[] bUii, byte[] bReadData, byte[] bErrorCode, byte flagCrc);
    public static native boolean UhfWriteDataByEPC (int fileDescriptor, byte[] bAccessPwd, byte bank, byte[] bPtr, byte cnt, byte[] bUii, byte[] bWriteData, byte[] bErrorCode, byte flagCrc);

    public static native boolean UhfEraseDataByEPC (int fileDescriptor, byte[] uAccessPwd, byte uBank, byte[] uPtr, byte uCnt, byte[] uUii, byte[] uErrorCode, byte flagCrc);
    public static native boolean UhfLockMemByEPC (int fileDescriptor, byte[] uAccessPwd, byte[] uLockData, byte[] uUii, byte[] uErrorCode, byte flagCrc);
    public static native boolean UhfKillTagByEPC (int fileDescriptor, byte[] uKillPwd, byte[] uUii, byte[] uErrorCode, byte flagCrc);
    public static native boolean UhfGetVersion (int fileDescriptor, byte[] uSerial, byte[] uVersion, byte flagCrc);

    public static native boolean UhfReadDataFromSingleTag (int fileDescriptor, byte[] bAccessPwd, byte bank, byte[] bPtr, byte cnt, byte[] bReadData, byte[] bUii, byte[] bLenUii, byte[] bErrorCode, byte flagCrc);
    public static native boolean UhfWriteDataToSingleTag (int fileDescriptor, byte[] bAccessPwd, byte bank, byte[] bPtr, byte cnt, byte[] bWriteData, byte[] bUii, byte[] bLenUii, byte[] bErrorCode, byte flagCrc);

    public static native boolean UhfBlockWriteDataByEPC (int fileDescriptor, byte[] uAccessPwd, byte uBank, byte[] uPtr, byte uCnt, byte[] uUii, byte[] uWriteData, byte[] uErrorCode, byte[] uStatus, byte[] uWritedLen, byte[] RuUii, byte flagCrc);
    public static native boolean UhfReadMaxDataByEPC (int fileDescriptor, byte[] uAccessPwd, byte uBank, byte[] uPtr, byte[] uUii, byte[] Data_len, byte[] uReadData, byte[] uErrorCode, byte flagCrc);
    public static native boolean UhfReadMaxDataFromSingleTag (int fileDescriptor, byte[] uAccessPwd, byte uBank, byte[] uPtr, byte[] Data_len, byte[] uReadData, byte[] uUii, byte[] uLenUii, byte[] uErrorCode, byte flagCrc);
    public static native boolean UhfEraseDataFromSingleTag  (int fileDescriptor, byte[] uAccessPwd, byte uBank, byte[] uPtr, byte uCnt, byte[] uUii, byte[] uErrorCode, byte flagCrc);
    public static native boolean UhfLockMemFromSingleTag (int fileDescriptor, byte[] uAccessPwd, byte[] uLockData, byte[] uUii, byte[] uErrorCode, byte flagCrc);
    public static native boolean UhfKillSingleTag (int fileDescriptor, byte[] uKillPwd, byte[] uUii, byte[] uErrorCode, byte flagCrc);
    public static native boolean UhfBlockWriteDataToSingleTag (int fileDescriptor, byte[] uAccessPwd, byte uBank, byte[] uPtr, byte uCnt, byte[] uWriteData, byte[] uUii, byte[] uLenUii, byte[] uStatus, byte[] uErrorCode, byte[] uWritedLen, byte flagCrc);
    public static native boolean UhfStartReadDataFromMultiTag (int fileDescriptor, byte[] uAccessPwd, byte uBank, byte[] uPtr, byte uCnt, byte uOption, byte[] uPayLoad, byte flagCrc);
    public static native boolean UhfGetDataFromMultiTag (int fileDescriptor, byte[] uStatus, byte[] ufData_len, byte[] ufReadData, byte[] usData_len, byte[] usReadData, byte[] uUii, byte[] uLenUii);
    public static native boolean UhfGetRegister (int fileDescriptor, int RADD, int RLEN, byte[] STATUS, byte[] REG, byte flagCrc);
    public static native boolean UhfSetRegister (int fileDescriptor, int RADD, int RLEN, byte[] REG_DATA, byte[] STATUS, byte flagCrc);
    public static native boolean UhfResetRegister (int fileDescriptor, byte flagCrc);
    public static native boolean UhfSaveRegister (int fileDescriptor, byte flagCrc);

    public static native boolean UhfEnterSleepMode (int fileDescriptor, byte flagCrc);
    public static native int UhfUpdateInit (String port, int baudRate, byte[] STATUS, byte[] RN32, byte flagCrc);
    public static native boolean UhfUpdateSendRN32 (int fileDescriptor, byte[] RN32, byte[] STATUS, byte flagCrc);
    public static native boolean UhfUpdateSendSize (int fileDescriptor, byte[] STATUS, byte[] FILESIZE, byte flagCrc);
    public static native boolean UhfUpdateSendData (int fileDescriptor, byte[] STATUS, byte PACKNUM, byte LASTPACK, int Data_len, byte[] TRANDATA, byte flagCrc);
    public static native boolean UhfUpdateCommit  (int fileDescriptor, byte[] STATUS, byte flagCrc);
    public static native boolean UhfBlockWriteEPCToSingleTag (int fileDescriptor, byte[] uAccessPwd, byte uCnt, byte[] uWriteData, byte[] uUii, byte[] uLenUii, byte[] uStatus, byte[] uErrorCode, byte[] uWritedLen, byte flagCrc);
    public static native boolean UhfBlockWriteEPCByEPC (int fileDescriptor, byte[] uAccessPwd, byte uCnt, byte[] uUii, byte[] uWriteData, byte[] uErrorCode, byte[] uStatus, byte[] uWritedLen, byte[] RuUii, byte flagCrc);

    public static native boolean UhfAddFilter (int fileDescriptor, byte Sindex, byte Target, byte Action, byte bank, byte[] Ptr, byte[] Mask, byte Truncate, byte[] STATUS, byte flagCrc);
    public static native boolean UhfDeleteFilterByIndex (int fileDescriptor, byte SINDEX, byte[] STATUS, byte flagCrc);
    public static native boolean UhfStartGetFilterByIndex (int fileDescriptor, byte SINDEX, byte SNUM, byte[] STATUS, byte flagCrc);
    public static native boolean UhfReadFilterByIndex(int fileDescriptor, byte[] STATUS, byte[] Sindex, byte[] Slen, byte[] Target, byte[] Action, byte[] bank, byte[] Ptr, byte[] Len, byte[] Mask, byte[] Truncate);
    public static native boolean UhfSelectFilterByIndex (int fileDescriptor, byte SINDEX, byte SNUM, byte[] STATUS, byte flagCrc);

    static{
        System.loadLibrary("UhfReaderCom");
        System.loadLibrary("UhfReader");
    }
}
